package stack;

import java.util.LinkedList;
import java.util.Objects;
import java.util.Queue;
import java.util.Stack;

public class MaxWindow {


    private final  LinkedList<Integer> queue = new LinkedList<>();

    private int rightIndex = 0;

    private final int width;

    private final int[] array;

    public static void main(String[] args) {

        MaxWindow maxWindow = new MaxWindow(new int[]{4, 3, 5, 4, 3, 3, 6, 7}, 3);
        maxWindow.rightMove();
        for (Integer integer : maxWindow.queue) {
            System.out.println(integer);
        }

    }

    public MaxWindow(int[] array, int width) {
        this.width = width;
        this.array = array;
    }

    private void rightMove() {

        if(queue.isEmpty()){
            queue.add(rightIndex);
            rightIndex++;
            rightMove();
        }

        Integer lastIndex = queue.peekLast();

        if(array[rightIndex]>array[lastIndex]){

            queue.add(rightIndex++);
        }else{

            queue.removeLast();

            rightMove();
        }

    }



}
